import BossType from "./enum/boss";

const { ccclass, property } = cc._decorator;

@ccclass
export default class Boss extends cc.Component {

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    // update (dt) {}
    @property(cc.AudioClip)
    bossDie: cc.AudioClip



    AudioSource: cc.AudioSource
    anim
    aniName
    onLoad() {
        this.anim = this.node.getComponent(sp.Skeleton)
        this.anim.animation = BossType.bossShow

        this.anim.setCompleteListener(() =>{
            if(this.aniName == BossType.bossDie){
                cc.systemEvent.emit("gameover")
            }else{
                 this.anim.animation = BossType.bossWait
            }
            
        })

        this.AudioSource = this.node.getComponent(cc.AudioSource)
    }

    start() {
        // 注册
    }
    playAudio(audioClip: cc.AudioClip, isLoop) {
        this.AudioSource.clip = audioClip
        if (isLoop) {
            this.AudioSource.loop = true
        }
        this.AudioSource.play()
    }

    setAni(aniName) {
        this.aniName = aniName
        this.anim.animation = this.aniName
    }

    // update (dt) {}
}


